class Solution {
public:
    int alternatingSubarray(vector<int>& a) {
        int ma = -1;
        int n = a.size();
        bool f = 0;
        for (int i = 0; i < n; i++) {
            int x = 1;
            int j = i + 1;
            int t = i;
            while (j < n && t < n && a[j] - a[t] == x) {
                x *= -1;
                j++;
                t++;
                f = 1;
            }
            cout << "t==" << t << endl;
            cout << "i==" << i << endl;
            cout << "j==" << j << endl;
            ma = max(ma, j - i);
        }
        if (!f)return -1;
        return ma;
    }
};